
/**
 * 用户信息管理
 * anyi
 */

export function getTokenUserid() {
  var user_cache_userid = getUserInfo();
  if (user_cache_userid?.userid != null) {
    return user_cache_userid?.userid;
  }
  return null;
}

export function getUseridType() {
  var user_cache_userid = getUserInfo();
  if (user_cache_userid?.types != null) {
    return user_cache_userid?.types;
  }
  return null;
}

export function getUseridAuthority() {
  var user_cache_userid = getUserInfo();
  if (user_cache_userid?.authority != null) {
    return user_cache_userid?.authority;
  }
  return null;
}

export function getinfotypes() {
  var user_cache_usertypes = getUserInfo();
  if (user_cache_usertypes?.types != null) {
    return user_cache_usertypes?.types;
  }
  return null;
}

export function getinfoname() {
  var user_cache_usertypes = getUserInfo();
  if (user_cache_usertypes?.username != null) {
    return user_cache_usertypes?.username;
  }
  return null;
}
export function getUserToken() {
  var user_cache_userinfo = getUserInfo();
  if (user_cache_userinfo?.token != null) {
    return user_cache_userinfo?.token;
  }
  return null;
}

export function setUserInfo(usercache: {}) {
  var user_cache = JSON.stringify(usercache);
  return localStorage.setItem("userinfo_key", user_cache);
}

// 获取
export function getUserInfo() {
  var user_cache_gets = localStorage.getItem("userinfo_key");
  var user_cache_get_token = JSON.parse(user_cache_gets as string);
  return user_cache_get_token;
}
// 删除
export function removeToken() {
  localStorage.clear();
  return localStorage.removeItem("userinfo_key");
}
//退出系统
export function logOut() {
  removeToken();
  return true;
}


